package cn.wolfcode.trip.base.service.impl;

import cn.wolfcode.trip.base.domain.Region;
import cn.wolfcode.trip.base.domain.User;
import cn.wolfcode.trip.base.mapper.RegionMapper;
import cn.wolfcode.trip.base.mapper.UserMapper;
import cn.wolfcode.trip.base.query.QueryObject;
import cn.wolfcode.trip.base.service.IRegionService;
import cn.wolfcode.trip.base.service.IUserService;
import com.github.pagehelper.PageHelper;
import com.github.pagehelper.PageInfo;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.List;

/**
 * Created by 13925 on 2018/10/28.
 */

/**
 * 地区服务实现类
 */
@Service
public class RegionServiceImpl implements IRegionService {

    @Autowired
    private RegionMapper regionMapper;

    public List<Region> getRegionByParentId(String parentId) {
        return regionMapper.getRegionByParentId(parentId);
    }

    @Override
    public void saveOrUpdate(Region region) {
        if (region.getId() != null) {
            regionMapper.updateByPrimaryKey(region);
        } else {
            regionMapper.insert(region);
        }
    }

    @Override
    public List<Region> selectAll() {
        return regionMapper.selectAll();
    }

    @Override
    public List<Region> listByState(Long  state) {
        return regionMapper.listByState(state);
    }
}
